
package ro.qi.framework.sys.users.entities;

import java.util.Date;

import ro.qi.framework.sys.common.PhoneNumber;
import ro.qi.framework.sys.entities.Entity;


public class UsersAccount extends Entity {

	public static final int STATE_OFFLINE			= 0;
	public static final int STATE_ONLINE			= 1;

	public static final int STATUS_NOT_VALIDATED	= 0;
	public static final int STATUS_VALID			= 1;
	public static final int STATUS_BLOCKED			= 20;
	public static final int STATUS_DELETED			= 99;

	public static final String GENDER_MALE			= "m";
	public static final String GENDER_FEMALE		= "f";
	 
	public static final String GENDER[]				= {GENDER_MALE, GENDER_FEMALE};

	public UsersAccount() {
		super();
	}

	public UsersAccount(int id) {
		super();
		setId(id);
		select();
	}

	public UsersAccount(String login) {
		super();
		setLogin(login);
		select();
	}

	public UsersAccount(String login, String email) {
		super();
		setLogin(login);
		setEmail(email);
		select();
	}

	public void setId(int value) {
		setValue("id", value);
	}

	public int getId() {
		return getIntValue("id");
	}

	public void setLogin(String value) {
		setValue("login", value);
	}

	public String getLogin() {
		return getStringValue("login");
	}

	public void setPassword(String value) {
		setValue("password", value);
	}

	public String getPassword() {
		return getStringValue("password");
	}

	public void setPasswordSalt(String value) {
		setValue("passwordSalt", value);
	}

	public String getPasswordSalt() {
		return getStringValue("passwordSalt");
	}

	public void setEmail(String value) {
		setValue("email", value);
	}

	public String getEmail() {
		return getStringValue("email");
	}

	public void setChallengeQuestion(String value) {
		setValue("challengeQuestion", value);
	}

	public String getChallengeQuestion() {
		return getStringValue("challengeQuestion");
	}

	public void setChallengeAnswer(String value) {
		setValue("challengeAnswer", value);
	}

	public String getChallengeAnswer() {
		return getStringValue("challengeAnswer");
	}

	public void setTitle(String value) {
		setValue("title", value);
	}

	public String getTitle() {
		return getStringValue("title");
	}

	public void setFirstName(String value) {
		setValue("firstName", value);
	}

	public String getFirstName() {
		return getStringValue("firstName");
	}

	public void setMiddleName(String value) {
		setValue("middleName", value);
	}

	public String getMiddleName() {
		return getStringValue("middleName");
	}

	public void setFamilyName(String value) {
		setValue("familyName", value);
	}

	public String getFamilyName() {
		return getStringValue("familyName");
	}

	public void setGenderId(String value) {
		setValue("genderId", value);
	}

	public String getGenderId() {
		return getStringValue("genderId");
	}

	public void setBirthdate(Date value) {
		setValue("birthdate", value);
	}

	public Date getBirthdate() {
		return getDateValue("birthdate");
	}

	public void setCountryId(int value) {
		setValue("countryId", value);
	}

	public int getCountryId() {
		return getIntValue("countryId");
	}

	public void setCountyId(int value) {
		setValue("countyId", value);
	}

	public int getCountyId() {
		return getIntValue("countyId");
	}

	public void setPostalCode(String value) {
		setValue("postalCode", value);
	}

	public String getPostalCode() {
		return getStringValue("postalCode");
	}

	public void setCity(String value) {
		setValue("city", value);
	}

	public String getCity() {
		return getStringValue("city");
	}

	public void setOfficePhone(String value) {
		setValue("officePhone", value);
	}

	public String getOfficePhone() {
		return getStringValue("officePhone");
	}
	
	public void setMobilePhone(String value) {
		setValue("mobilePhone", value);
	}

	public String getMobilePhone() {
		return getStringValue("mobilePhone");
	}
	
	public void setAutologin(boolean value) {
		setValue("autologin", value);
	}

	public boolean getAutologin() {
		return getBooleanValue("autologin");
	}

	public void setStatus(int value) {
		setValue("status", value);
	}

	public int getStatus() {
		return getIntValue("status");
	}

	public void setState(int value) {
		setValue("state", value);
	}

	public int getState() {
		return getIntValue("state");
	}

	public void setCreatedIpAddress(String value) {
		setValue("createdIpAddress", value);
	}

	public String getCreatedIpAddress() {
		return getStringValue("createdIpAddress");
	}

	public void setUpdatedIpAddress(String value) {
		setValue("updatedIpAddress", value);
	}

	public String getUpdatedIpAddress() {
		return getStringValue("updatedIpAddress");
	}

	public Date getCreateTime() {
		return getDateValue("createTime");
	}

	public Date getUpdateTime() {
		return getDateValue("updateTime");
	}

	public PhoneNumber getOfficePhoneNumber() {
		return new PhoneNumber(getOfficePhone());
	}

	/*
	 * 
	 */
	public PhoneNumber getMobilePhoneNumber() {
		return new PhoneNumber(getMobilePhone());
	}

	public String getName() {
		StringBuffer name = new StringBuffer();
		
		if (getFirstName().trim().length() > 0) {
			name.append(getFirstName() + " ");
		}
		
		if (getFamilyName().trim().length() > 0) {
			name.append(getFamilyName());
		}
		
		return name.toString().trim();
	}
	
	public String getFullName() {
		StringBuffer fullName = new StringBuffer();
		
		if (getFirstName().trim().length() > 0) {
			fullName.append(getFirstName() + " ");
		}
		
		if (getMiddleName().trim().length() > 0) {
			fullName.append(getMiddleName() + " ");
		}
		
		if (getFamilyName().trim().length() > 0) {
			fullName.append(getFamilyName());
		}
		
		return fullName.toString().trim();
	}
	
	/*
	 * @deprecated use setGenderId()
	 */
	public void setGender(String value) {
		setValue("genderId", value);
	}

	/*
	 * @deprecated use getGenderId()
	 */
	public String getGender() {
		return getStringValue("genderId");
	}

	/*
	 * @deprecated use getOfficePhoneNumber() or getMobilePhoneNumber()
	 */
//	public PhoneNumber getPhoneNumber() {
//		return new PhoneNumber(getPhone());
//	}
	
	/*
	 * @deprecated use setOfficePhone or setMobilePhone
	 */
//	public void setPhone(String value) {
//		setValue("phone", value);
//	}

	/*
	 * @deprecated use getOfficePhone or getMobilePhone
	 */
//	public String getPhone() {
//		return getStringValue("phone");
//	}

}
